#include "FindPwdChangePwdDlg.h"

#include <core/ImageMgr.h>
#include <core/StyleMgr.h>
#include <widgets/SLineEdit.h>
#include <widgets/SPopupWindow.h>

#include <QGridLayout>
#include <QLabel>
#include <QPaintDevice>
#include <QPainter>
#include <QPushButton>
#include <QSpacerItem>
#include <QStylePainter>
#include <QWidget>

FindPwdChangePwdDlg::FindPwdChangePwdDlg(QWidget* p /*= nullptr*/)
    : QWidget(p) {
  // step_3: 更改密码
  QVBoxLayout* vL = new QVBoxLayout(this);
  vL->setContentsMargins(0, 4, 0, 0);

  QLabel* accountNameLabel = new QLabel(tr("您的账户为:"), this);
  accountNameLabel->setStyleSheet(
      QString("font:15px Microsoft YaHei;color:#%1")
          .arg(StyleMgr::instance().color("Highlight").rgb(), 0, 16));
  vL->addWidget(accountNameLabel, 0, Qt::AlignLeft);
  vL->addSpacing(25);

  QLabel* setNewPwdLabel = new QLabel(tr("设置新密码"), this);
  vL->addWidget(setNewPwdLabel, 0, Qt::AlignLeft);
  vL->addSpacing(12);

  m_setNewPwdEdit = new SLineEdit("", this);
  m_setNewPwdEdit->setSelectAllWhenFocus(true);
  m_setNewPwdEdit->setFixedSize(384, 40);
  m_setNewPwdEdit->setPlaceholderText(tr("密码必须是8-20位数字、英文字母组合"));
  m_setNewPwdEdit->setEchoMode(QLineEdit::Password);
  QFont f = m_setNewPwdEdit->font();
  f.setPixelSize(15);
  m_setNewPwdEdit->setFont(f);
  vL->addWidget(m_setNewPwdEdit, 0, Qt::AlignLeft);
  vL->addSpacing(33);

  m_verifyPwdEDit = new SLineEdit("", this);
  m_verifyPwdEDit->setSelectAllWhenFocus(true);
  m_verifyPwdEDit->setFixedSize(384, 40);
  m_verifyPwdEDit->setPlaceholderText(tr("请再次输入新密码"));
  m_verifyPwdEDit->setEchoMode(QLineEdit::Password);
  m_verifyPwdEDit->setFont(f);
  vL->addWidget(m_verifyPwdEDit, 0, Qt::AlignLeft);
  AddPwdEdit();
}

void FindPwdChangePwdDlg::AddPwdEdit() {
  m_changePwdEdit.push_back(m_setNewPwdEdit);
  m_changePwdEdit.push_back(m_verifyPwdEDit);
}
